package com.manong.web.controller;

import com.manong.domain.Menu;
import com.manong.domain.MenuRole;
import com.manong.service.MenuService;
import com.manong.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/menu")
@CrossOrigin(allowCredentials = "true")
public class MenuController {

    @Autowired
    private MenuService menuService;

    /**
     * 分页查询接口
     * @param
     * @return
     */
    @GetMapping("/allMenu")
    public JsonResult allMenu() {
        List<Menu> menus = menuService.getMenus();
        return JsonResult.success(menus);
    }

    /**
     * 分页查询接口
     * @param
     * @return
     */
    @GetMapping("/getMenuRoleById/{id}")
    public JsonResult getMenuRoleById(@PathVariable Long id) {
        List<MenuRole> menus = menuService.getMenusByRole(id);
        return JsonResult.success(menus);
    }


}
